import api from '../http'
import { QueryData, DataModel, LibraryQueryModel } from './model'

//获取药品列表
export const apiList = (params: QueryData) => {
  return api({
    url: '/drugs/list',
    method: 'GET',
    params,
  })
}

//新增
export const apiAddDrugs = (data: DataModel) => {
  return api({
    url: '/drugs/add',
    method: 'POST',
    data,
  })
}

//获取药品详情
export const apiDrugsDetails = (drugsId: number) => {
  return api({
    url: `/drugs/${drugsId}`,
    method: 'GET',
  })
}

//修改
export const apiUpdateDrugs = (data: DataModel) => {
  return api({
    url: '/drugs/update',
    method: 'PUT',
    data,
  })
}

//删除
export const apiDeleteDrugs = (drugsId: number) => {
  return api({
    url: `/drugs/${drugsId}`,
    method: 'DELETE',
  })
}

//通过药品名称获取药品信息
export const apiQueryKey = (params: any) => {
  return api({
    url: `/drugs/queryKey`,
    method: 'GET',
    params,
  })
}

//获取药品库数据
export const apiPageList = (params: LibraryQueryModel) => {
  return api({
    url: `/drugs/library/list`,
    method: 'GET',
    params,
  })
}

//将药品数据添加到社区里
export const apiPushStore = (data: any) => {
  return api({
    url: `/drugs/library/store`,
    method: 'POST',
    data,
  })
}

//直接删除某个药品的库存
export const apiDeleteStore = (params: any) => {
  return api({
    url: `/drugs/library/delete`,
    method: 'DELETE',
    params,
  })
}

//修改某个药品的库存
export const apiEditStore = (data: any) => {
  return api({
    url: `/drugs/library/edit`,
    method: 'POST',
    data,
  })
}

//通过关键字查询某个社区的药品库数据
export const apiQueryLibrary = (params: any) => {
  return api({
    url: `/drugs/library/queryKey`,
    method: 'GET',
    params,
  })
}

//通过药品库的药品id获取药品信息
export const apiLibraryDetails = (params: any) => {
  return api({
    url: `/drugs/library/details`,
    method: 'GET',
    params,
  })
}
